<template>
	<view class="safety homePage ">
		<view class="headerBox home-top" :style="{paddingTop: systemBarHeight + 'px'}">
		</view>
		<view class="mine">
			<view class="mine_content">
				<!----------------- 我的服务------------------ -->
				<view class="mine_box">
					<view class="mine_box_t">
						<view class="title">常用功能</view>
					</view>
					<view class="my_service">
						<view v-for="(v,index) in serviceTypeList" :key="index">
							<view class="oneLine flex-center" @click="linkTo(v.url,v.type)">
								<image class="service_img"
									:src="v.img.startsWith('https://') ? v.img : `https://wx.2024csnl.com/static/mine/${v.img}.png`"
									mode=""></image>
								<view class="service_name">{{v.name}}</view>
							</view>
						</view>
					</view>
				</view>
				<!-- 客服popup -->
				<uni-popup ref="popup" type="bottom">
					<view class="popBox">
						<view class="phoneNum">15386436268</view>
						<view style="color: #0084FF;" @click="callPhone('15386436268')">呼叫</view>
						<view class="cancel" @click="close('popup')">取消</view>
					</view>
				</uni-popup>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPersonalCenter,
		getVersions,
		getAppConfigSync
	} from "../../api/index.js"
	export default {
		data() {
			return {
				versionNumber: getApp().globalData.versionNumber,
				systemBarHeight: getApp().globalData.systemBarHeight,
				serviceTypeList: []
			}
		},
		onLoad() {
			const appConfig = getAppConfigSync()

			this.isShowUserLevel = appConfig.isShowUserLevel
			this.isShowMyProperty = appConfig.isShowMyProperty
			this.serviceTypeList = appConfig.funList

		},
		onShow() {},
		methods: {

			// 复制
			onCopy(value, name) {
				uni.setClipboardData({
					data: value.toString(),
					success: () => {
						console.log(value)
						this.showToast(`复制${name}成功~`)
					}
				});
			},
			// 扫码核销
			onChargeOff() {
				let that = this


				uni.scanCode({
					onlyFromCamera: true,
					autoZoom: false,
					success: (res) => {
						this.showToast(res.result)
					}
				});

			},
			linkTo(url, type) {
				if (url == 'server') {
					this.open('popup')
				} else {
					if (type == 'three') {
						uni.switchTab({
							url
						})
					} else {
						let router = ''

						if (type == 'one') {
							router = `/package/mine/${url}`
						} else if (type == 'two') {
							router = url
						} else {
							if (url.indexOf("community") == 0) {
								router = `/package/mine/mycommunity/mycommunity`
							} else {
								router = `/package/mine/${url}/${url}`
							}
						}
						uni.navigateTo({
							url: router
						})
					}

				}

			},
			open(n) {
				this.$refs[n].open();
			},
			close(n) {
				this.$refs[n].close();
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
	}

	.badgeBox {
		z-index: 99;
		position: absolute;
		top: -40rpx;
		right: 20rpx;
	}

	.homePage {
		.headerBox {
			position: fixed;
			left: 0;
			right: 0;
			top: 0;
			z-index: 999;
		}
	}

	.popBox {
		font-size: 30rpx;
		background: #fff;
		border-radius: 40rpx 40rpx 0px 0px;

		.phoneNum {
			color: #999999;
			font-size: 24rpx;
		}

		view {
			padding: 50rpx 0;
			text-align: center;
			border-bottom: 1px solid #F3F3F3;
		}

		.cancel {
			border-top: 12rpx solid #F3F3F3;
			color: #333333;
		}
	}

	.mine {
		.mine_t {
			margin-top: -50rpx;
			width: 100%;
			height: 540upx;
			position: relative;

			image {
				width: 100%;
				height: 540upx;
			}

			>view {
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
				z-index: 2;
				padding: 110upx 22upx 0;
				box-sizing: border-box;

				.user {
					display: flex;
					justify-content: space-between;
					margin-bottom: 34upx;

					.user_info {
						display: flex;
						align-items: center;
						color: #fff;

						>image {
							width: 100upx;
							height: 100upx;
							border-radius: 50%;
							margin-right: 18upx;
						}

						>view {
							.user_name {
								font-size: 30upx;
								line-height: 30upx;
								font-weight: Medium;
								margin-bottom: 20upx;

								image {
									width: 60upx;
									border-radius: 10rpx;
									height: 60upx;
								}
							}

							.lv {
								display: inline-flex;
								align-items: center;

								text {
									font-size: 26rpx;
									margin: 0 10rpx 0 30rpx;
								}

								.nickName {
									max-width: 200rpx;
									margin-right: 15rpx;
									line-height: 45rpx;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap
								}
							}

							.other_info {
								display: flex;
								align-items: center;

								view {
									font-size: 22upx;
									line-height: 22upx;
								}


							}
						}
					}

					.btn {
						position: absolute;
						right: 30rpx;
						top: 180rpx;

						>view {
							width: 130upx;
							height: 52upx;
							background-color: rgba(#000, 0.3);
							border-radius: 26upx;
							font-size: 22upx;
							color: #fff;
							font-weight: Medium;
							display: flex;
							align-items: center;

							image {
								padding-left: 30upx;
								width: 30upx;
								height: 30upx;
								margin-right: 14upx;
							}
						}
					}
				}

				.banner {
					width: 100%;
					height: 234upx;
					background-color: #fff;
					border-radius: 14upx;

					.banner_t {
						padding: 28upx 22upx;
						box-sizing: border-box;
						display: flex;
						justify-content: space-between;
						border-bottom: 1upx solid #F3F3F3;

						.title {
							font-size: 26upx;
							color: #302D2D;
							font-weight: Medium;
						}

						.more {
							display: flex;
							align-items: center;

							text {
								font-size: 22upx;
								color: #A9A9A9;
								margin-right: 8upx;
							}
						}
					}

					.order_type {
						display: flex;
						justify-content: space-between;
						padding: 32upx 50upx 0;

						.type_item {
							>view {
								display: flex;
								justify-content: center;

								image {
									width: 44upx;
									height: 44upx;
								}
							}

							.type_name {
								font-size: 24upx;
								line-height: 24upx;
								padding-top: 18upx;
							}
						}
					}
				}
			}
		}

		.mine_content {
			padding: 10upx 20upx;
			box-sizing: border-box;

			.mine_box {
				width: 100%;
				background-color: #fff;
				border-radius: 10upx;
				margin-bottom: 20upx;

				.mine_box_t {
					padding: 26upx 32upx 26upx 22upx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					border-bottom: 1px solid #FBFBFB;

					.title {
						font-size: 18px;
						font-weight: bold;
					}

					.more {
						display: flex;
						align-items: center;

						text {
							font-size: 22upx;
							color: #A9A9A9;
							margin-right: 8upx;
						}
					}
				}

				.my_assets {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 30upx 52upx;
					box-sizing: border-box;

					.asset_item {
						text-align: center;
						flex: 1;

						.asset_val {
							line-height: 36upx;
							margin-bottom: 16upx;

							text {
								font-size: 26upx;
								font-weight: bold;
								color: #41644A;
							}

							image {
								width: 38upx;
								height: 36upx;
							}
						}

						.asset_name {
							font-size: 24upx;
							line-height: 24upx;
						}
					}
				}

				.my_service {
					display: grid;
					grid-template-columns: repeat(4, 1fr);
					padding: 20upx 0 0;
					box-sizing: border-box;

					.oneLine {

						flex-direction: column;
						margin-bottom: 50upx;
					}

					.service_img {
						width: 48upx;
						height: 48upx;
						line-height: 48upx;

					}

					.service_name {
						font-size: 24upx;
						margin-top: 20upx;
					}
				}
			}
		}

	}
</style>